<?php

class Admin_Form_Category extends Twitter_Bootstrap_Form_Horizontal
{
	public function getFormId() {
		$className = get_class($this);
		return strtolower($className);
	}

    public function init()
    {
        $this->setIsArray(true);
        //$this->setElementsBelongTo('bootstrap');

        $this->_addClassNames('form-horizontal');

        // Category name
        $this->addElement('text', 'name', array(
            'id' => $this->getFormId().'_name',
        	'label' => $this->getView()->translate('NAME'),
            'maxlength' => 45,
        	'class' => 'input-xlarge'
        ));
        $this->getElement('name')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setRequired(true)
                ->addValidators(array(
                    array('NotEmpty', true),
                    array('stringLength', false, array(3, 45)),
                ));
                
        // Published
        $this->addElement('radio', 'published', array(
            'id' => $this->getFormId().'_published',
        	'label' => $this->getView()->translate('PUBLISHED'),
        	'multiOptions' => array('yes' => $this->getView()->translate('YES_'), 'no' => $this->getView()->translate('NO_')),
        	'value' => 'yes'
        ));
        $this->getElement('published')
                ->addFilter('StringTrim')
                ->addFilter('StripTags')
                ->setRequired(true)
                ->addValidators(array(
                    array('NotEmpty', true)
                ));
                
        // Id
        $this->addElement('hidden', 'id', array(
            'id' => $this->getFormId().'_id'
        ));        
        $this->getElement('id')->removeDecorator('Wrapper')->removeDecorator('HtmlTag');
        
        // Section Id
        $this->addElement('hidden', 'section_id', array(
            'id' => $this->getFormId().'_section_id'
        ));
        $this->getElement('section_id')
                ->setRequired(true)
                ->addValidators(array());
        $this->getElement('section_id')->removeDecorator('Wrapper')->removeDecorator('HtmlTag');
    }
}